package com.niit.web.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.niit.bean.Blog;
import com.niit.service.BlogService;
import com.niit.service.QuestionService;
import com.niit.service.impl.BlogServiceImpl;
import com.niit.service.impl.QuestionServiceImpl;
import com.niit.utils.Page;

@WebServlet("/ShowBrief4BlogQuesController")
public class ShowBrief4BlogQuesController extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		BlogService bs = new BlogServiceImpl();
		Page<Blog> blogs = bs.getPage(null, null);
		request.setAttribute("blogs", blogs);
		
		QuestionService qs = new QuestionServiceImpl();
		List<Object[]> questions = qs.findQuesAndCount4Reply();
		request.setAttribute("questions", questions);
		
		request.getRequestDispatcher("/jsp/user/plaza.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
